package com.example.mvp.delegate;

import android.content.Context;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * View公共托管类
 * Created by sun.li on 2018/6/13.
 *
 * @author sun.li
 */

public abstract class BaseViewDelegate implements XDelegate{

    private View rootView;

    protected final SparseArray<View> mViews = new SparseArray<View>();

    @Override
    public void create(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                int rootLayoutId = initLayoutRes();
        try {
            rootView = inflater.inflate(rootLayoutId,container);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public View getRootView() {
        return rootView;
    }

    /**
     * 初始化界面布局文件
     */
    protected abstract int initLayoutRes();
}
